package org.zfes.snowier.zbss.xzy.router.face;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.face.model.Face;
import org.zfes.snowier.zbss.xzy.biz.face.service.IFaceService;
import org.zfes.snowier.core.data.SelectVo;
@Controller("org.zfes.snowier.zbss.xzy.router.face.FaceController")
@RequestMapping("/manger/face")
public class FaceController implements BaseController {

	
	@Autowired
	private IFaceService faceService;
	
	//@RequiresPermissions(value="face:loadFaceDataSet",desc="人脸列表")
    @RequestMapping(value="/loadFaceDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadFaceDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  faceService.loadFaceDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="face:createFace",desc="人脸添加")
    @RequestMapping(value="/createFace", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createFace(@RequestBody Face face){
		faceService.createFace(face);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="face:loadFace",desc="人脸加载")
    @RequestMapping(value="/loadFace/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadFace(@PathVariable("id")Long id){
		Optional<Face> ops = faceService.loadFaceById(id);
		return ajaxQuery("face",ops);
    }
	
	//@RequiresPermissions(value="face:updateFace",desc="人脸更新")
    @RequestMapping(value="/updateFace", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateFace(@RequestBody  Face face){
		faceService.updateFace(face);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="face:deletFace",desc="人脸删除")
    @RequestMapping(value="/deleteFace/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteFace(@PathVariable("id")Long id){
		faceService.deleteFace(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadFaceSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadFaceSelectVo(){
		 List<SelectVo>  ops = faceService.loadFaceSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
}